<?php 
class ExportCsvFile {
	const DEFAULT_EXPORT_NAME = 'Export_csv';
    public static function createCsvFile($data,$csv_name=DEFAULT_EXPORT_NAME) {
    	if (!$data) {
    		echo json_encode(array('status'=>'failing','data'=>'the data is empty!'));
    		exit;
    	}
    	header("Content-Type: application/vnd.ms-execl");
		header("Content-Disposition: attachment; filename={$csv_name}.csv");
		header("Pragma: no-cache");
		header("Expires: 0");
		echo mb_convert_encoding($data,'gb2312','UTF-8');
		exit;
    }
   
}


?>